package com.yudedu.hospital.service.impl;


import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.yudedu.hospital.entity.Appointment;
import com.yudedu.hospital.entity.BranchCourts;
import com.yudedu.hospital.entity.CaseHistery;
import com.yudedu.hospital.entity.Department;
import com.yudedu.hospital.entity.Doctor;
import com.yudedu.hospital.entity.Page;
import com.yudedu.hospital.entity.User;
import com.yudedu.hospital.entity.UserLogin;
import com.yudedu.hospital.mapper.AppointmentMapper;
import com.yudedu.hospital.mapper.BranchCourtsMapper;
import com.yudedu.hospital.mapper.CaseHisteryMapper;
import com.yudedu.hospital.mapper.DepartmentMapper;
import com.yudedu.hospital.mapper.DoctorMapper;
import com.yudedu.hospital.mapper.UserLoginMapper;
import com.yudedu.hospital.mapper.UserMapper;
import com.yudedu.hospital.service.UserService;


@Service
public class UserServiceImpl implements UserService{


	
	@Resource
	private UserLoginMapper loginMapper;
	@Resource
	private CaseHisteryMapper caseHisteryMapper;
	@Resource
	private AppointmentMapper appointmentMapper;
	@Resource
	private UserMapper userMapper;
	@Resource
	private BranchCourtsMapper branchCourtsMapper;
	@Resource
	private DepartmentMapper departmentMapper;
	@Resource
	private DoctorMapper doctorMapper;
	
	
	private UserLogin user;
	private List<CaseHistery> caseHistery;
	private List<Appointment> appointment;
	private UserLogin userMessage;
	private User userMsg;
	private UserLogin testUser;
	private List<BranchCourts> branchCourt;
	private List<Department> department ;
	private List<Doctor> doctors;


	
	public UserLogin query() {
//		System.out.println(loginMapper.query());
		return loginMapper.query();
	}

	@Override
	public UserLogin login(String username, String password) {
		user = loginMapper.login(username, password);
		return user;
	}

	@Override
	public void editPassword(String renewpass,int id) {
		  loginMapper.edit(renewpass,id);
	}

	@Override
	public List<CaseHistery> queryCaseHistery(int user_id) {
		caseHistery = caseHisteryMapper.query(user_id);
		return caseHistery ;
	}

	@Override
	public List<Appointment> queryAppointment(int user_id) {
		System.out.println(user_id+"---");
		appointment = appointmentMapper.query(user_id);
		return appointment;
	}

	@Override
	public void editUserMessage(int user_id, String name, String sex, String idCard, String birthday, String userPhone,
			String address, String QQ, String zipCode, String email) {
		userMapper.edit(user_id,name,sex,idCard,birthday,userPhone,address,QQ,zipCode,email);
		
	}

	@Override
	public void deleCaseHistery(int id) {
		caseHisteryMapper.deleCaseHistery(id);
		
	}

	@Override
	public void deleAppointment(int id) {
		appointmentMapper.deleAppointment(id);
		
	}

	@Override
	public void register(String username, String password) {
		loginMapper.register(username,password);
		
	}

	@Override
	public User queryMsg(int id) {
		userMsg=userMapper.query(id);
		return userMsg;
	}

	@Override
	public void insertUserMessage(int user_id, String name, String sex, String idCard, String birthday,
			String userPhone, String address, String QQ, String zipCode, String email) {
		userMapper.insert(user_id,name,sex,idCard,birthday,userPhone,address,QQ,zipCode,email);
	}

	@Override
	public UserLogin query(String username, String password) {
		testUser = loginMapper.queryUser(username,password);
		return testUser;
		
	}

	@Override
	public List<BranchCourts> querybranchCourts() {
		branchCourt = branchCourtsMapper.queryBranchCourts();
		return branchCourt;
	}

	@Override
	public List<BranchCourts> querybranchCourts(String pa) {
		branchCourt = branchCourtsMapper.queryBranchCourts(pa);
		return branchCourt;
	}

	@Override
	public List<Department> queryDepartment() {
	  department = departmentMapper.queryDepartment();
		return department;
	}

	@Override
	public List<Doctor> queryDoctor(Integer branch_id, Integer depart_id) {
		doctors=doctorMapper.queryDoctors(branch_id,depart_id);
		return doctors;
	}

	@Override
	public List<Doctor> queryDoctor(int doctor_id) {
		List<Doctor> doctor = doctorMapper.queryDoctor(doctor_id);
		return doctor;
	}

	@Override
	public void addAppointment(String hospitalName, String address, String tele, String departments, String doctor,
			String date, String email, String doctorTele,int user_id) {
		appointmentMapper.addAppointment(hospitalName,address,tele,departments,doctor,date,email,doctorTele,user_id);
		
	}

	@Override
	public void editAppointment(int id,String hospitalName, String address, String tele, String departments, String doctor,
			String date, String email, String doctorTele) {
		appointmentMapper.editAppointment(id,hospitalName,address,tele,departments,doctor,date,email,doctorTele);
		
	}

	@Override
	public UserLogin querycx(String username) {
		user = loginMapper.querycx(username);
		return user;
	}

	@Override
	public void editPicture(String pictureUrl,int id) {
		System.out.println(pictureUrl+id+".........");
		userMapper.editPicture(pictureUrl,id);
	}

	@Override
	public List<CaseHistery> queryPageCaseHistery() {
		List<CaseHistery> pages = caseHisteryMapper.queryPageCaseHistery();
		return pages;
	}

	@Override
	public List<CaseHistery> queryPageCaseHistery(String mes) {
		List<CaseHistery> pages = caseHisteryMapper.queryPageCaseHistery1(mes);
		return pages;
	}



}
